home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 3.8 KB | 130 lines | [TEXT/MPS ] |
- // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
- // UDrawShapes.h
-
- #ifndef __USHAPESDOCUMENT__
- #define __USHAPESDOCUMENT__
-
- #ifndef __UFILEBASEDDOCUMENT__
- #include <UFileBasedDocument.h>
- #endif
-
- #ifndef __USHAPELIST__
- #include "UShapeList.h"
- #endif
-
- class TShape;
- class TShapeReplaceCommand;
- class TShapeView;
-
- //--------------------------------------------------------------------------------------------------
- // Document state: stored in the Resource Fork of the document file; holds the
- // following general properties of the document, necessary for rereading
- // a saved document and restoring the appearance of the window (location,
- // size, and scrolling) to its state when last saved }
-
- struct DocState {
- short theNumberOfShapes;
- VPoint theLocation;
- VPoint theSize;
- VPoint theScrollPosition;
- };
-
- typedef DocState* PDocState; // Pointer to DocState information
- typedef PDocState* HDocState; // Handle to DocState information
-
- //--------------------------------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------------------------------
- // TShapeDocument
- //--------------------------------------------------------------------------------------------------
- class TShapeDocument : public TFileBasedDocument
- {
- MA_DECLARE_CLASS;
-
- friend class CShapeIterator;
- friend class TShapeCutCopyCommand;
-
- public:
- TShapeDocument(); // Constructor
-
- void IShapeDocument(TFile* itsFile);
-
- virtual void Free(); // Override
- virtual void FreeData(); // Override
-
- // • Adding/deleting shapes
- void AddShape(TShape* shape);
- void DeleteShape(TShape* shape);
-
- // • Overrides of basic TDocument methods
- virtual void DoMakeViews(Boolean forPrinting); // Override
-
- virtual void DoSetupMenus(); // Override
-
- virtual void DoNeedDiskSpace(TFile* itsFile,
- long& dataForkBytes,
- long& rsrcForkBytes); // Override
-
- virtual void DoRead(TFile* aFile, Boolean forPrinting); // Override
- virtual void DoWrite(TFile* aFile, Boolean makingCopy); // Override
-
- virtual void ReadFrom(TStream* aStream); // Override
- virtual void WriteTo(TStream* aStream); // Override
-
- // • Shape list iteration
- void EachShapeDo(DoToShapeType DoToShape, void* staticLink);
-
- void EachShapeMaybeDo(DoToShapeType DoToShape, void* staticLink);
-
- void EachPotentialShapeDo(DoToShapeType DoToShape, void* staticLink);
-
- void EachVirtualShapeDo(DoToShapeType DoToShape, void* staticLink);
-
- TShape* FirstSelectedShape();
-
- // • Misc
-
- inline TShapeList* GetShapeList() { return fShapeList; };
- inline Boolean IsFiltering() { return fFiltering; };
- inline void SetFiltering(Boolean filtering) { fFiltering = filtering; };
-
- void RestoreWindow(TWindow* aWindow);
-
- PicHandle ShapesAsPict(TList* aShapeList);
-
- void SurveyShapes(Boolean selecteesOnly, short& numberOfShapes, CRect& combinedExtent);
-
- TShapeReplaceCommand* fReplaceCommand;
-
- TShapeView* fShapeView;
-
- // • Shape utilities
-
- TShape* ShapeUnderMouse(CPoint qdPt);
- void DeselectShapes();
- void RestoreSelection(TShapeView* shapeView);
- void DrawShapes(CRect& qdArea, Boolean dragging);
- void HiliteShapes(TShapeView* shapeView, HLState fromHL, HLState toHL);
- void SaveSelection(TShapeView* shapeView, Boolean andInval);
- void SelectAllShapes(TShapeView* shapeView);
- Boolean CursorInShape(CPoint qdPoint, RgnHandle cursorRegion);
- void AnyShapesSelected(Boolean& anySelection, Boolean& anyShapes);
- void ShapesBeInView(TShapeView* shapeView);
- TView* MakeClipView();
-
- private:
- TShapeList* fShapeList;
- DocState fDocState;
- Boolean fReopening;
- Boolean fFiltering;
-
- void CreateProceduralShapeView();
- // Used when creating views procedurally to create the shapesView for both
- // printing and non-printing cases
-
- void AddPrintHandlerToView(TView* theView);
- // Used to add a standard print handler to the shape view
- };
-
- #endif
-